<!DOCTYPE HTML>
<html lang="zh-CN">


<head>
    <meta charset="utf-8">
    <meta name="keywords" content="typescript10（语法扩展）, W.BOWEN&#39;s blog">
    <meta name="description" content="接受失败,但不选择放弃">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
    <meta name="renderer" content="webkit|ie-stand|ie-comp">
    <meta name="mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
    <!-- Global site tag (gtag.js) - Google Analytics -->


    <title>typescript10（语法扩展） | W.BOWEN&#39;s blog</title>
    <link rel="icon" type="image/png" href="/wangbowen-hexo-blog/favicon.png">

    <link rel="stylesheet" type="text/css" href="/wangbowen-hexo-blog/libs/awesome/css/all.css">
    <link rel="stylesheet" type="text/css" href="/wangbowen-hexo-blog/libs/materialize/materialize.min.css">
    <link rel="stylesheet" type="text/css" href="/wangbowen-hexo-blog/libs/aos/aos.css">
    <link rel="stylesheet" type="text/css" href="/wangbowen-hexo-blog/libs/animate/animate.min.css">
    <link rel="stylesheet" type="text/css" href="/wangbowen-hexo-blog/libs/lightGallery/css/lightgallery.min.css">
    <link rel="stylesheet" type="text/css" href="/wangbowen-hexo-blog/css/matery.css">
    <link rel="stylesheet" type="text/css" href="/wangbowen-hexo-blog/css/my.css">

    <script src="/wangbowen-hexo-blog/libs/jquery/jquery.min.js"></script>

<meta name="generator" content="Hexo 5.3.0"></head>




<body>
    <header class="navbar-fixed">
    <nav id="headNav" class="bg-color nav-transparent">
        <div id="navContainer" class="nav-wrapper container">
            <div class="brand-logo">
                <a href="/wangbowen-hexo-blog/" class="waves-effect waves-light">
                    
                    <img src="/wangbowen-hexo-blog/medias/logo.png" class="logo-img" alt="LOGO">
                    
                    <span class="logo-span">W.BOWEN&#39;s blog</span>
                </a>
            </div>
            

<a href="#" data-target="mobile-nav" class="sidenav-trigger button-collapse"><i class="fas fa-bars"></i></a>
<ul class="right nav-menu">
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/wangbowen-hexo-blog/" class="waves-effect waves-light">
      
      <i class="fas fa-home" style="zoom: 0.6;"></i>
      
      <span>首页</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/wangbowen-hexo-blog/tags" class="waves-effect waves-light">
      
      <i class="fas fa-tags" style="zoom: 0.6;"></i>
      
      <span>标签</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/wangbowen-hexo-blog/categories" class="waves-effect waves-light">
      
      <i class="fas fa-bookmark" style="zoom: 0.6;"></i>
      
      <span>分类</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/wangbowen-hexo-blog/archives" class="waves-effect waves-light">
      
      <i class="fas fa-archive" style="zoom: 0.6;"></i>
      
      <span>归档</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/wangbowen-hexo-blog/about" class="waves-effect waves-light">
      
      <i class="fas fa-user-circle" style="zoom: 0.6;"></i>
      
      <span>关于</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/wangbowen-hexo-blog/contact" class="waves-effect waves-light">
      
      <i class="fas fa-comments" style="zoom: 0.6;"></i>
      
      <span>留言板</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/wangbowen-hexo-blog/friends" class="waves-effect waves-light">
      
      <i class="fas fa-address-book" style="zoom: 0.6;"></i>
      
      <span>友情链接</span>
    </a>
    
  </li>
  
  <li>
    <a href="#searchModal" class="modal-trigger waves-effect waves-light">
      <i id="searchIcon" class="fas fa-search" title="搜索" style="zoom: 0.85;"></i>
    </a>
  </li>
</ul>


<div id="mobile-nav" class="side-nav sidenav">

    <div class="mobile-head bg-color">
        
        <img src="/wangbowen-hexo-blog/medias/logo.png" class="logo-img circle responsive-img">
        
        <div class="logo-name">W.BOWEN&#39;s blog</div>
        <div class="logo-desc">
            
            接受失败,但不选择放弃
            
        </div>
    </div>

    

    <ul class="menu-list mobile-menu-list">
        
        <li class="m-nav-item">
	  
		<a href="/wangbowen-hexo-blog/" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-home"></i>
			
			首页
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/wangbowen-hexo-blog/tags" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-tags"></i>
			
			标签
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/wangbowen-hexo-blog/categories" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-bookmark"></i>
			
			分类
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/wangbowen-hexo-blog/archives" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-archive"></i>
			
			归档
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/wangbowen-hexo-blog/about" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-user-circle"></i>
			
			关于
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/wangbowen-hexo-blog/contact" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-comments"></i>
			
			留言板
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/wangbowen-hexo-blog/friends" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-address-book"></i>
			
			友情链接
		</a>
          
        </li>
        
        
        <li><div class="divider"></div></li>
        <li>
            <a href="https://gitee.com/wang-bowen" class="waves-effect waves-light" target="_blank">
                <i class="fab fa-github-square fa-fw"></i>Fork Me
            </a>
        </li>
        
    </ul>
</div>


        </div>

        
            <style>
    .nav-transparent .github-corner {
        display: none !important;
    }

    .github-corner {
        position: absolute;
        z-index: 10;
        top: 0;
        right: 0;
        border: 0;
        transform: scale(1.1);
    }

    .github-corner svg {
        color: #0f9d58;
        fill: #fff;
        height: 64px;
        width: 64px;
    }

    .github-corner:hover .octo-arm {
        animation: a 0.56s ease-in-out;
    }

    .github-corner .octo-arm {
        animation: none;
    }

    @keyframes a {
        0%,
        to {
            transform: rotate(0);
        }
        20%,
        60% {
            transform: rotate(-25deg);
        }
        40%,
        80% {
            transform: rotate(10deg);
        }
    }
</style>

<a href="https://gitee.com/wang-bowen" class="github-corner tooltipped hide-on-med-and-down" target="_blank"
   data-tooltip="Fork Me" data-position="left" data-delay="50">
    <svg viewBox="0 0 250 250" aria-hidden="true">
        <path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path>
        <path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2"
              fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path>
        <path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z"
              fill="currentColor" class="octo-body"></path>
    </svg>
</a>
        
    </nav>

</header>

    



<div class="bg-cover pd-header post-cover" style="background-image: url('/wangbowen-hexo-blog/medias/featureimages/9.jpg')">
    <div class="container" style="right: 0px;left: 0px;">
        <div class="row">
            <div class="col s12 m12 l12">
                <div class="brand">
                    <h1 class="description center-align post-title">typescript10（语法扩展）</h1>
                </div>
            </div>
        </div>
    </div>
</div>




<main class="post-container content">

    
    <link rel="stylesheet" href="/wangbowen-hexo-blog/libs/tocbot/tocbot.css">
<style>
    #articleContent h1::before,
    #articleContent h2::before,
    #articleContent h3::before,
    #articleContent h4::before,
    #articleContent h5::before,
    #articleContent h6::before {
        display: block;
        content: " ";
        height: 100px;
        margin-top: -100px;
        visibility: hidden;
    }

    #articleContent :focus {
        outline: none;
    }

    .toc-fixed {
        position: fixed;
        top: 64px;
    }

    .toc-widget {
        width: 345px;
        padding-left: 20px;
    }

    .toc-widget .toc-title {
        padding: 35px 0 15px 17px;
        font-size: 1.5rem;
        font-weight: bold;
        line-height: 1.5rem;
    }

    .toc-widget ol {
        padding: 0;
        list-style: none;
    }

    #toc-content {
        padding-bottom: 30px;
        overflow: auto;
    }

    #toc-content ol {
        padding-left: 10px;
    }

    #toc-content ol li {
        padding-left: 10px;
    }

    #toc-content .toc-link:hover {
        color: #42b983;
        font-weight: 700;
        text-decoration: underline;
    }

    #toc-content .toc-link::before {
        background-color: transparent;
        max-height: 25px;

        position: absolute;
        right: 23.5vw;
        display: block;
    }

    #toc-content .is-active-link {
        color: #42b983;
    }

    #floating-toc-btn {
        position: fixed;
        right: 15px;
        bottom: 76px;
        padding-top: 15px;
        margin-bottom: 0;
        z-index: 998;
    }

    #floating-toc-btn .btn-floating {
        width: 48px;
        height: 48px;
    }

    #floating-toc-btn .btn-floating i {
        line-height: 48px;
        font-size: 1.4rem;
    }
</style>
<div class="row">
    <div id="main-content" class="col s12 m12 l9">
        <!-- 文章内容详情 -->
<div id="artDetail">
    <div class="card">
        <div class="card-content article-info">
            <div class="row tag-cate">
                <div class="col s7">
                    
                    <div class="article-tag">
                        
                            <a href="/wangbowen-hexo-blog/tags/typescript/">
                                <span class="chip bg-color">typescript</span>
                            </a>
                        
                    </div>
                    
                </div>
                <div class="col s5 right-align">
                    
                </div>
            </div>

            <div class="post-info">
                
                <div class="post-date info-break-policy">
                    <i class="far fa-calendar-minus fa-fw"></i>发布日期:&nbsp;&nbsp;
                    2023-03-11
                </div>
                

                

                

                

                
            </div>
        </div>
        <hr class="clearfix">

        

        

        <div class="card-content article-card-content">
            <div id="articleContent">
                <h2 id="内置类型导入"><a href="#内置类型导入" class="headerlink" title="内置类型导入"></a>内置类型导入</h2><ul>
<li><p>导入时需要使用type前缀,表明被导入的是一个类型</p>
<figure class="highlight ts"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> <span class="keyword">type</span> &#123; MyInterface, MyType &#125; <span class="keyword">from</span> <span class="string">&quot;./index&quot;</span>;</span><br><span class="line"></span><br><span class="line"><span class="keyword">const</span> v1: MyType = <span class="string">&quot;wangbowen&quot;</span></span><br><span class="line"><span class="keyword">const</span> v2: MyInterface = &#123;</span><br><span class="line">  name: <span class="string">&#x27;wangbowen&#x27;</span>,</span><br><span class="line">  age: <span class="number">18</span></span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h2 id="tsconfig-json"><a href="#tsconfig-json" class="headerlink" title="tsconfig.json"></a>tsconfig.json</h2></li>
<li><p>tsconfig.json文件是通过<code>tsc --init</code>生成</p>
<figure class="highlight"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br></pre></td><td class="code"><pre><span class="line">&quot;compilerOptions&quot;: &#123;</span><br><span class="line">  &quot;incremental&quot;: true, // TS编译器在第一次编译之后会生成一个存储编译信息的文件，第二次编译会在第一次的基础上进行增量编译，可以提高编译的速度</span><br><span class="line">  &quot;tsBuildInfoFile&quot;: &quot;./buildFile&quot;, // 增量编译文件的存储位置</span><br><span class="line">  &quot;diagnostics&quot;: true, // 打印诊断信息 </span><br><span class="line">  &quot;target&quot;: &quot;ES5&quot;, // 目标语言的版本</span><br><span class="line">  &quot;module&quot;: &quot;CommonJS&quot;, // 生成代码的模板标准</span><br><span class="line">  &quot;outFile&quot;: &quot;./app.js&quot;, // 将多个相互依赖的文件生成一个文件，可以用在AMD模块中，即开启时应设置&quot;module&quot;: &quot;AMD&quot;,</span><br><span class="line">  &quot;lib&quot;: [&quot;DOM&quot;, &quot;ES2015&quot;, &quot;ScriptHost&quot;, &quot;ES2019.Array&quot;], // TS需要引用的库，即声明文件，es5 默认引用dom、es5、scripthost,如需要使用es的高级版本特性，通常都需要配置，如es8的数组新特性需要引入&quot;ES2019.Array&quot;,</span><br><span class="line">  &quot;allowJS&quot;: true, // 允许编译器编译JS，JSX文件</span><br><span class="line">  &quot;checkJs&quot;: true, // 允许在JS文件中报错，通常与allowJS一起使用</span><br><span class="line">  &quot;outDir&quot;: &quot;./dist&quot;, // 指定输出目录</span><br><span class="line">  &quot;rootDir&quot;: &quot;./&quot;, // 指定输出文件目录(用于输出)，用于控制输出目录结构</span><br><span class="line">  &quot;declaration&quot;: true, // 生成声明文件，开启后会自动生成声明文件</span><br><span class="line">  &quot;declarationDir&quot;: &quot;./file&quot;, // 指定生成声明文件存放目录</span><br><span class="line">  &quot;emitDeclarationOnly&quot;: true, // 只生成声明文件，而不会生成js文件</span><br><span class="line">  &quot;sourceMap&quot;: true, // 生成目标文件的sourceMap文件</span><br><span class="line">  &quot;inlineSourceMap&quot;: true, // 生成目标文件的inline SourceMap，inline SourceMap会包含在生成的js文件中</span><br><span class="line">  &quot;declarationMap&quot;: true, // 为声明文件生成sourceMap</span><br><span class="line">  &quot;typeRoots&quot;: [], // 声明文件目录，默认时node_modules/@types</span><br><span class="line">  &quot;types&quot;: [], // 加载的声明文件包</span><br><span class="line">  &quot;removeComments&quot;:true, // 删除注释 </span><br><span class="line">  &quot;noEmit&quot;: true, // 不输出文件,即编译后不会生成任何js文件</span><br><span class="line">  &quot;noEmitOnError&quot;: true, // 发送错误时不输出任何文件</span><br><span class="line">  &quot;noEmitHelpers&quot;: true, // 不生成helper函数，减小体积，需要额外安装，常配合importHelpers一起使用</span><br><span class="line">  &quot;importHelpers&quot;: true, // 通过tslib引入helper函数，文件必须是模块</span><br><span class="line">  &quot;downlevelIteration&quot;: true, // 降级遍历器实现，如果目标源是es3/5，那么遍历器会有降级的实现</span><br><span class="line">  &quot;strict&quot;: true, // 开启所有严格的类型检查</span><br><span class="line">  &quot;alwaysStrict&quot;: true, // 在代码中注入&#x27;use strict&#x27;</span><br><span class="line">  &quot;noImplicitAny&quot;: true, // 不允许隐式的any类型</span><br><span class="line">  &quot;strictNullChecks&quot;: true, // 不允许把null、undefined赋值给其他类型的变量</span><br><span class="line">  &quot;strictFunctionTypes&quot;: true, // 不允许函数参数双向协变</span><br><span class="line">  &quot;strictPropertyInitialization&quot;: true, // 类的实例属性必须初始化</span><br><span class="line">  &quot;strictBindCallApply&quot;: true, // 严格的bind/call/apply检查</span><br><span class="line">  &quot;noImplicitThis&quot;: true, // 不允许this有隐式的any类型</span><br><span class="line">  &quot;noUnusedLocals&quot;: true, // 检查只声明、未使用的局部变量(只提示不报错)</span><br><span class="line">  &quot;noUnusedParameters&quot;: true, // 检查未使用的函数参数(只提示不报错)</span><br><span class="line">  &quot;noFallthroughCasesInSwitch&quot;: true, // 防止switch语句贯穿(即如果没有break语句后面不会执行)</span><br><span class="line">  &quot;noImplicitReturns&quot;: true, //每个分支都会有返回值</span><br><span class="line">  &quot;esModuleInterop&quot;: true, // 允许export=导出，由import from 导入</span><br><span class="line">  &quot;allowUmdGlobalAccess&quot;: true, // 允许在模块中全局变量的方式访问umd模块</span><br><span class="line">  &quot;moduleResolution&quot;: &quot;node&quot;, // 模块解析策略，ts默认用node的解析策略，即相对的方式导入</span><br><span class="line">  &quot;baseUrl&quot;: &quot;./&quot;, // 解析非相对模块的基地址，默认是当前目录</span><br><span class="line">  &quot;paths&quot;: &#123; // 路径映射，相对于baseUrl</span><br><span class="line">    <span class="comment">// 如使用jq时不想使用默认版本，而需要手动指定版本，可进行如下配置</span></span><br><span class="line">    &quot;jquery&quot;: [&quot;node_modules/jquery/dist/jquery.min.js&quot;]</span><br><span class="line">  &#125;,</span><br><span class="line">  &quot;rootDirs&quot;: [&quot;src&quot;,&quot;out&quot;], // 将多个目录放在一个虚拟目录下，用于运行时，即编译后引入文件的位置可能发生变化，这也设置可以虚拟src和out在同一个目录下，不用再去改变路径也不会报错</span><br><span class="line">  &quot;listEmittedFiles&quot;: true, // 打印输出文件</span><br><span class="line">  &quot;listFiles&quot;: true// 打印编译的文件(包括引用的声明文件)</span><br><span class="line">&#125;</span><br><span class="line"> </span><br><span class="line"><span class="comment">// 指定一个匹配列表（属于自动指定该路径下的所有ts相关文件）</span></span><br><span class="line">&quot;include&quot;: [</span><br><span class="line">   <span class="string">&quot;src/**/*&quot;</span></span><br><span class="line">],</span><br><span class="line"><span class="comment">// 指定一个排除列表（include的反向操作）</span></span><br><span class="line"> &quot;exclude&quot;: [</span><br><span class="line">   <span class="string">&quot;demo.ts&quot;</span></span><br><span class="line">],</span><br><span class="line"><span class="comment">// 指定哪些文件使用该配置（属于手动一个个指定文件）</span></span><br><span class="line"> &quot;files&quot;: [</span><br><span class="line">   <span class="string">&quot;demo.ts&quot;</span></span><br><span class="line">]</span><br></pre></td></tr></table></figure>
<h2 id="内置类型声明"><a href="#内置类型声明" class="headerlink" title="内置类型声明"></a>内置类型声明</h2></li>
</ul>
<figure class="highlight ts"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">let</span> body: HTMLElement = <span class="built_in">document</span>.body;</span><br><span class="line"><span class="keyword">let</span> allDiv: NodeList = <span class="built_in">document</span>.querySelectorAll(<span class="string">&#x27;div&#x27;</span>);</span><br><span class="line"><span class="comment">//读取div 这种需要类型断言 或者加个判断应为读不到返回null</span></span><br><span class="line"><span class="keyword">let</span> div:HTMLElement = <span class="built_in">document</span>.querySelector(<span class="string">&#x27;div&#x27;</span>) <span class="keyword">as</span> HTMLDivElement</span><br><span class="line"><span class="built_in">document</span>.addEventListener(<span class="string">&#x27;click&#x27;</span>, <span class="function"><span class="keyword">function</span> (<span class="params">e: MouseEvent</span>) </span>&#123;&#125;);</span><br><span class="line"><span class="comment">//dom元素的映射表</span></span><br><span class="line"><span class="keyword">interface</span> HTMLElementTagNameMap &#123;</span><br><span class="line">  <span class="string">&quot;a&quot;</span>: HTMLAnchorElement;</span><br><span class="line">  <span class="string">&quot;abbr&quot;</span>: HTMLElement;</span><br><span class="line">  <span class="string">&quot;address&quot;</span>: HTMLElement;</span><br><span class="line">  <span class="string">&quot;applet&quot;</span>: HTMLAppletElement;</span><br><span class="line">  <span class="string">&quot;area&quot;</span>: HTMLAreaElement;</span><br><span class="line">  <span class="string">&quot;article&quot;</span>: HTMLElement;</span><br><span class="line">  <span class="string">&quot;aside&quot;</span>: HTMLElement;</span><br><span class="line">  <span class="string">&quot;audio&quot;</span>: HTMLAudioElement;</span><br><span class="line">  <span class="string">&quot;b&quot;</span>: HTMLElement;</span><br><span class="line">  <span class="string">&quot;base&quot;</span>: HTMLBaseElement;</span><br><span class="line">  <span class="string">&quot;bdi&quot;</span>: HTMLElement;</span><br><span class="line">  <span class="string">&quot;bdo&quot;</span>: HTMLElement;</span><br><span class="line">  <span class="string">&quot;blockquote&quot;</span>: HTMLQuoteElement;</span><br><span class="line">  <span class="string">&quot;body&quot;</span>: HTMLBodyElement;</span><br><span class="line">  <span class="string">&quot;br&quot;</span>: HTMLBRElement;</span><br><span class="line">  <span class="string">&quot;button&quot;</span>: HTMLButtonElement;</span><br><span class="line">  <span class="string">&quot;canvas&quot;</span>: HTMLCanvasElement;</span><br><span class="line">  <span class="string">&quot;caption&quot;</span>: HTMLTableCaptionElement;</span><br><span class="line">  <span class="string">&quot;cite&quot;</span>: HTMLElement;</span><br><span class="line">  <span class="string">&quot;code&quot;</span>: HTMLElement;</span><br><span class="line">  <span class="string">&quot;col&quot;</span>: HTMLTableColElement;</span><br><span class="line">  <span class="string">&quot;colgroup&quot;</span>: HTMLTableColElement;</span><br><span class="line">  <span class="string">&quot;data&quot;</span>: HTMLDataElement;</span><br><span class="line">  <span class="string">&quot;datalist&quot;</span>: HTMLDataListElement;</span><br><span class="line">  <span class="string">&quot;dd&quot;</span>: HTMLElement;</span><br><span class="line">  <span class="string">&quot;del&quot;</span>: HTMLModElement;</span><br><span class="line">  <span class="string">&quot;details&quot;</span>: HTMLDetailsElement;</span><br><span class="line">  <span class="string">&quot;dfn&quot;</span>: HTMLElement;</span><br><span class="line">  <span class="string">&quot;dialog&quot;</span>: HTMLDialogElement;</span><br><span class="line">  <span class="string">&quot;dir&quot;</span>: HTMLDirectoryElement;</span><br><span class="line">  <span class="string">&quot;div&quot;</span>: HTMLDivElement;</span><br><span class="line">  <span class="string">&quot;dl&quot;</span>: HTMLDListElement;</span><br><span class="line">  <span class="string">&quot;dt&quot;</span>: HTMLElement;</span><br><span class="line">  <span class="string">&quot;em&quot;</span>: HTMLElement;</span><br><span class="line">  <span class="string">&quot;embed&quot;</span>: HTMLEmbedElement;</span><br><span class="line">  <span class="string">&quot;fieldset&quot;</span>: HTMLFieldSetElement;</span><br><span class="line">  <span class="string">&quot;figcaption&quot;</span>: HTMLElement;</span><br><span class="line">  <span class="string">&quot;figure&quot;</span>: HTMLElement;</span><br><span class="line">  <span class="string">&quot;font&quot;</span>: HTMLFontElement;</span><br><span class="line">  <span class="string">&quot;footer&quot;</span>: HTMLElement;</span><br><span class="line">  <span class="string">&quot;form&quot;</span>: HTMLFormElement;</span><br><span class="line">  <span class="string">&quot;frame&quot;</span>: HTMLFrameElement;</span><br><span class="line">  <span class="string">&quot;frameset&quot;</span>: HTMLFrameSetElement;</span><br><span class="line">  <span class="string">&quot;h1&quot;</span>: HTMLHeadingElement;</span><br><span class="line">  <span class="string">&quot;h2&quot;</span>: HTMLHeadingElement;</span><br><span class="line">  <span class="string">&quot;h3&quot;</span>: HTMLHeadingElement;</span><br><span class="line">  <span class="string">&quot;h4&quot;</span>: HTMLHeadingElement;</span><br><span class="line">  <span class="string">&quot;h5&quot;</span>: HTMLHeadingElement;</span><br><span class="line">  <span class="string">&quot;h6&quot;</span>: HTMLHeadingElement;</span><br><span class="line">  <span class="string">&quot;head&quot;</span>: HTMLHeadElement;</span><br><span class="line">  <span class="string">&quot;header&quot;</span>: HTMLElement;</span><br><span class="line">  <span class="string">&quot;hgroup&quot;</span>: HTMLElement;</span><br><span class="line">  <span class="string">&quot;hr&quot;</span>: HTMLHRElement;</span><br><span class="line">  <span class="string">&quot;html&quot;</span>: HTMLHtmlElement;</span><br><span class="line">  <span class="string">&quot;i&quot;</span>: HTMLElement;</span><br><span class="line">  <span class="string">&quot;iframe&quot;</span>: HTMLIFrameElement;</span><br><span class="line">  <span class="string">&quot;img&quot;</span>: HTMLImageElement;</span><br><span class="line">  <span class="string">&quot;input&quot;</span>: HTMLInputElement;</span><br><span class="line">  <span class="string">&quot;ins&quot;</span>: HTMLModElement;</span><br><span class="line">  <span class="string">&quot;kbd&quot;</span>: HTMLElement;</span><br><span class="line">  <span class="string">&quot;label&quot;</span>: HTMLLabelElement;</span><br><span class="line">  <span class="string">&quot;legend&quot;</span>: HTMLLegendElement;</span><br><span class="line">  <span class="string">&quot;li&quot;</span>: HTMLLIElement;</span><br><span class="line">  <span class="string">&quot;link&quot;</span>: HTMLLinkElement;</span><br><span class="line">  <span class="string">&quot;main&quot;</span>: HTMLElement;</span><br><span class="line">  <span class="string">&quot;map&quot;</span>: HTMLMapElement;</span><br><span class="line">  <span class="string">&quot;mark&quot;</span>: HTMLElement;</span><br><span class="line">  <span class="string">&quot;marquee&quot;</span>: HTMLMarqueeElement;</span><br><span class="line">  <span class="string">&quot;menu&quot;</span>: HTMLMenuElement;</span><br><span class="line">  <span class="string">&quot;meta&quot;</span>: HTMLMetaElement;</span><br><span class="line">  <span class="string">&quot;meter&quot;</span>: HTMLMeterElement;</span><br><span class="line">  <span class="string">&quot;nav&quot;</span>: HTMLElement;</span><br><span class="line">  <span class="string">&quot;noscript&quot;</span>: HTMLElement;</span><br><span class="line">  <span class="string">&quot;object&quot;</span>: HTMLObjectElement;</span><br><span class="line">  <span class="string">&quot;ol&quot;</span>: HTMLOListElement;</span><br><span class="line">  <span class="string">&quot;optgroup&quot;</span>: HTMLOptGroupElement;</span><br><span class="line">  <span class="string">&quot;option&quot;</span>: HTMLOptionElement;</span><br><span class="line">  <span class="string">&quot;output&quot;</span>: HTMLOutputElement;</span><br><span class="line">  <span class="string">&quot;p&quot;</span>: HTMLParagraphElement;</span><br><span class="line">  <span class="string">&quot;param&quot;</span>: HTMLParamElement;</span><br><span class="line">  <span class="string">&quot;picture&quot;</span>: HTMLPictureElement;</span><br><span class="line">  <span class="string">&quot;pre&quot;</span>: HTMLPreElement;</span><br><span class="line">  <span class="string">&quot;progress&quot;</span>: HTMLProgressElement;</span><br><span class="line">  <span class="string">&quot;q&quot;</span>: HTMLQuoteElement;</span><br><span class="line">  <span class="string">&quot;rp&quot;</span>: HTMLElement;</span><br><span class="line">  <span class="string">&quot;rt&quot;</span>: HTMLElement;</span><br><span class="line">  <span class="string">&quot;ruby&quot;</span>: HTMLElement;</span><br><span class="line">  <span class="string">&quot;s&quot;</span>: HTMLElement;</span><br><span class="line">  <span class="string">&quot;samp&quot;</span>: HTMLElement;</span><br><span class="line">  <span class="string">&quot;script&quot;</span>: HTMLScriptElement;</span><br><span class="line">  <span class="string">&quot;section&quot;</span>: HTMLElement;</span><br><span class="line">  <span class="string">&quot;select&quot;</span>: HTMLSelectElement;</span><br><span class="line">  <span class="string">&quot;slot&quot;</span>: HTMLSlotElement;</span><br><span class="line">  <span class="string">&quot;small&quot;</span>: HTMLElement;</span><br><span class="line">  <span class="string">&quot;source&quot;</span>: HTMLSourceElement;</span><br><span class="line">  <span class="string">&quot;span&quot;</span>: HTMLSpanElement;</span><br><span class="line">  <span class="string">&quot;strong&quot;</span>: HTMLElement;</span><br><span class="line">  <span class="string">&quot;style&quot;</span>: HTMLStyleElement;</span><br><span class="line">  <span class="string">&quot;sub&quot;</span>: HTMLElement;</span><br><span class="line">  <span class="string">&quot;summary&quot;</span>: HTMLElement;</span><br><span class="line">  <span class="string">&quot;sup&quot;</span>: HTMLElement;</span><br><span class="line">  <span class="string">&quot;table&quot;</span>: HTMLTableElement;</span><br><span class="line">  <span class="string">&quot;tbody&quot;</span>: HTMLTableSectionElement;</span><br><span class="line">  <span class="string">&quot;td&quot;</span>: HTMLTableDataCellElement;</span><br><span class="line">  <span class="string">&quot;template&quot;</span>: HTMLTemplateElement;</span><br><span class="line">  <span class="string">&quot;textarea&quot;</span>: HTMLTextAreaElement;</span><br><span class="line">  <span class="string">&quot;tfoot&quot;</span>: HTMLTableSectionElement;</span><br><span class="line">  <span class="string">&quot;th&quot;</span>: HTMLTableHeaderCellElement;</span><br><span class="line">  <span class="string">&quot;thead&quot;</span>: HTMLTableSectionElement;</span><br><span class="line">  <span class="string">&quot;time&quot;</span>: HTMLTimeElement;</span><br><span class="line">  <span class="string">&quot;title&quot;</span>: HTMLTitleElement;</span><br><span class="line">  <span class="string">&quot;tr&quot;</span>: HTMLTableRowElement;</span><br><span class="line">  <span class="string">&quot;track&quot;</span>: HTMLTrackElement;</span><br><span class="line">  <span class="string">&quot;u&quot;</span>: HTMLElement;</span><br><span class="line">  <span class="string">&quot;ul&quot;</span>: HTMLUListElement;</span><br><span class="line">  <span class="string">&quot;var&quot;</span>: HTMLElement;</span><br><span class="line">  <span class="string">&quot;video&quot;</span>: HTMLVideoElement;</span><br><span class="line">  <span class="string">&quot;wbr&quot;</span>: HTMLElement;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h2 id="d-ts文件"><a href="#d-ts文件" class="headerlink" title=".d.ts文件"></a>.d.ts文件</h2><ul>
<li>用来做类型的声明(declare),称之为<code>类型声明</code>或者<code>类型定义</code>文件</li>
<li>它仅仅用来做类型检测,告知typescript有哪些类型</li>
<li>第三方库中如果没有声明文件可以使用<code>npm i @types/xxx --save-dev</code>进行下载</li>
</ul>
<h2 id="declare声明模块"><a href="#declare声明模块" class="headerlink" title="declare声明模块"></a>declare声明模块</h2><ul>
<li><p>声明模块语法：<code>declare module &#39;模块名&#39; &#123;&#125;</code></p>
</li>
<li><p>在声明模块的内部，我们<code>可以通过export导出对应的库的类、函数等</code></p>
<figure class="highlight ts"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">declare</span> <span class="built_in">module</span> <span class="string">&quot;lodash&quot;</span> &#123;</span><br><span class="line">  <span class="keyword">export</span> <span class="function"><span class="keyword">function</span> <span class="title">join</span>(<span class="params">args: <span class="built_in">any</span>[]</span>): <span class="title">any</span>[]</span></span><br><span class="line"><span class="function">&#125;</span></span><br></pre></td></tr></table></figure>
<h2 id="declare声明文件"><a href="#declare声明文件" class="headerlink" title="declare声明文件"></a>declare声明文件</h2></li>
<li><p>比如开发过程中，默认不识别.vue文件，那么我们需要对其进行文件声明</p>
</li>
<li><p>比如使用了jpg图片文件，默认typescript也不支持</p>
<figure class="highlight ts"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">declare</span> <span class="built_in">module</span> <span class="string">&#x27;*.vue&#x27;</span> &#123;&#125;</span><br><span class="line"><span class="keyword">declare</span> <span class="built_in">module</span> <span class="string">&#x27;*.jpg&#x27;</span> &#123;&#125;</span><br></pre></td></tr></table></figure></li>
</ul>

                
            </div>
            <hr/>

            

    <div class="reprint" id="reprint-statement">
        
            <div class="reprint__author">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-user">
                        文章作者:
                    </i>
                </span>
                <span class="reprint-info">
                    <a href="/wangbowen-hexo-blog/about" rel="external nofollow noreferrer">W.BOWEN</a>
                </span>
            </div>
            <div class="reprint__type">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-link">
                        文章链接:
                    </i>
                </span>
                <span class="reprint-info">
                    <a href="https://gitee.com/wang-bowen0629/wangbowen-hexo-blog/2023/03/11/typescript10-yu-fa-kuo-zhan/">https://gitee.com/wang-bowen0629/wangbowen-hexo-blog/2023/03/11/typescript10-yu-fa-kuo-zhan/</a>
                </span>
            </div>
            <div class="reprint__notice">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-copyright">
                        版权声明:
                    </i>
                </span>
                <span class="reprint-info">
                    本博客所有文章除特別声明外，均采用
                    <a href="https://creativecommons.org/licenses/by/4.0/deed.zh" rel="external nofollow noreferrer" target="_blank">CC BY 4.0</a>
                    许可协议。转载请注明来源
                    <a href="/wangbowen-hexo-blog/about" target="_blank">W.BOWEN</a>
                    !
                </span>
            </div>
        
    </div>

    <script async defer>
      document.addEventListener("copy", function (e) {
        let toastHTML = '<span>复制成功，请遵循本文的转载规则</span><button class="btn-flat toast-action" onclick="navToReprintStatement()" style="font-size: smaller">查看</a>';
        M.toast({html: toastHTML})
      });

      function navToReprintStatement() {
        $("html, body").animate({scrollTop: $("#reprint-statement").offset().top - 80}, 800);
      }
    </script>



            <div class="tag_share" style="display: block;">
                <div class="post-meta__tag-list" style="display: inline-block;">
                    
                        <div class="article-tag">
                            
                                <a href="/wangbowen-hexo-blog/tags/typescript/">
                                    <span class="chip bg-color">typescript</span>
                                </a>
                            
                        </div>
                    
                </div>
                <div class="post_share" style="zoom: 80%; width: fit-content; display: inline-block; float: right; margin: -0.15rem 0;">
                    <link rel="stylesheet" type="text/css" href="/wangbowen-hexo-blog/libs/share/css/share.min.css">
<div id="article-share">

    
    <div class="social-share" data-sites="twitter,facebook,google,qq,qzone,wechat,weibo,douban,linkedin" data-wechat-qrcode-helper="<p>微信扫一扫即可分享！</p>"></div>
    <script src="/wangbowen-hexo-blog/libs/share/js/social-share.min.js"></script>
    

    

</div>

                </div>
            </div>
            
                <style>
    #reward {
        margin: 40px 0;
        text-align: center;
    }

    #reward .reward-link {
        font-size: 1.4rem;
        line-height: 38px;
    }

    #reward .btn-floating:hover {
        box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2), 0 5px 15px rgba(0, 0, 0, 0.2);
    }

    #rewardModal {
        width: 320px;
        height: 350px;
    }

    #rewardModal .reward-title {
        margin: 15px auto;
        padding-bottom: 5px;
    }

    #rewardModal .modal-content {
        padding: 10px;
    }

    #rewardModal .close {
        position: absolute;
        right: 15px;
        top: 15px;
        color: rgba(0, 0, 0, 0.5);
        font-size: 1.3rem;
        line-height: 20px;
        cursor: pointer;
    }

    #rewardModal .close:hover {
        color: #ef5350;
        transform: scale(1.3);
        -moz-transform:scale(1.3);
        -webkit-transform:scale(1.3);
        -o-transform:scale(1.3);
    }

    #rewardModal .reward-tabs {
        margin: 0 auto;
        width: 210px;
    }

    .reward-tabs .tabs {
        height: 38px;
        margin: 10px auto;
        padding-left: 0;
    }

    .reward-content ul {
        padding-left: 0 !important;
    }

    .reward-tabs .tabs .tab {
        height: 38px;
        line-height: 38px;
    }

    .reward-tabs .tab a {
        color: #fff;
        background-color: #ccc;
    }

    .reward-tabs .tab a:hover {
        background-color: #ccc;
        color: #fff;
    }

    .reward-tabs .wechat-tab .active {
        color: #fff !important;
        background-color: #22AB38 !important;
    }

    .reward-tabs .alipay-tab .active {
        color: #fff !important;
        background-color: #019FE8 !important;
    }

    .reward-tabs .reward-img {
        width: 210px;
        height: 210px;
    }
</style>

<div id="reward">
    <a href="#rewardModal" class="reward-link modal-trigger btn-floating btn-medium waves-effect waves-light red">赏</a>

    <!-- Modal Structure -->
    <div id="rewardModal" class="modal">
        <div class="modal-content">
            <a class="close modal-close"><i class="fas fa-times"></i></a>
            <h4 class="reward-title">你的赏识是我前进的动力</h4>
            <div class="reward-content">
                <div class="reward-tabs">
                    <ul class="tabs row">
                        <li class="tab col s6 alipay-tab waves-effect waves-light"><a href="#alipay">支付宝</a></li>
                        <li class="tab col s6 wechat-tab waves-effect waves-light"><a href="#wechat">微 信</a></li>
                    </ul>
                    <div id="alipay">
                        <img src="/wangbowen-hexo-blog/medias/reward/alipay.jpg" class="reward-img" alt="支付宝打赏二维码">
                    </div>
                    <div id="wechat">
                        <img src="/wangbowen-hexo-blog/medias/reward/wechat.png" class="reward-img" alt="微信打赏二维码">
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
    $(function () {
        $('.tabs').tabs();
    });
</script>

            
        </div>
    </div>

    

    

    

    

    
        <style>
    .valine-card {
        margin: 1.5rem auto;
    }

    .valine-card .card-content {
        padding: 20px 20px 5px 20px;
    }

    #vcomments textarea {
        box-sizing: border-box;
        background: url("/wangbowen-hexo-blog/medias/comment_bg.png") 100% 100% no-repeat;
    }

    #vcomments p {
        margin: 2px 2px 10px;
        font-size: 1.05rem;
        line-height: 1.78rem;
    }

    #vcomments blockquote p {
        text-indent: 0.2rem;
    }

    #vcomments a {
        padding: 0 2px;
        color: #4cbf30;
        font-weight: 500;
        text-decoration: none;
    }

    #vcomments img {
        max-width: 100%;
        height: auto;
        cursor: pointer;
    }

    #vcomments ol li {
        list-style-type: decimal;
    }

    #vcomments ol,
    ul {
        display: block;
        padding-left: 2em;
        word-spacing: 0.05rem;
    }

    #vcomments ul li,
    ol li {
        display: list-item;
        line-height: 1.8rem;
        font-size: 1rem;
    }

    #vcomments ul li {
        list-style-type: disc;
    }

    #vcomments ul ul li {
        list-style-type: circle;
    }

    #vcomments table, th, td {
        padding: 12px 13px;
        border: 1px solid #dfe2e5;
    }

    #vcomments table, th, td {
        border: 0;
    }

    table tr:nth-child(2n), thead {
        background-color: #fafafa;
    }

    #vcomments table th {
        background-color: #f2f2f2;
        min-width: 80px;
    }

    #vcomments table td {
        min-width: 80px;
    }

    #vcomments h1 {
        font-size: 1.85rem;
        font-weight: bold;
        line-height: 2.2rem;
    }

    #vcomments h2 {
        font-size: 1.65rem;
        font-weight: bold;
        line-height: 1.9rem;
    }

    #vcomments h3 {
        font-size: 1.45rem;
        font-weight: bold;
        line-height: 1.7rem;
    }

    #vcomments h4 {
        font-size: 1.25rem;
        font-weight: bold;
        line-height: 1.5rem;
    }

    #vcomments h5 {
        font-size: 1.1rem;
        font-weight: bold;
        line-height: 1.4rem;
    }

    #vcomments h6 {
        font-size: 1rem;
        line-height: 1.3rem;
    }

    #vcomments p {
        font-size: 1rem;
        line-height: 1.5rem;
    }

    #vcomments hr {
        margin: 12px 0;
        border: 0;
        border-top: 1px solid #ccc;
    }

    #vcomments blockquote {
        margin: 15px 0;
        border-left: 5px solid #42b983;
        padding: 1rem 0.8rem 0.3rem 0.8rem;
        color: #666;
        background-color: rgba(66, 185, 131, .1);
    }

    #vcomments pre {
        font-family: monospace, monospace;
        padding: 1.2em;
        margin: .5em 0;
        background: #272822;
        overflow: auto;
        border-radius: 0.3em;
        tab-size: 4;
    }

    #vcomments code {
        font-family: monospace, monospace;
        padding: 1px 3px;
        font-size: 0.92rem;
        color: #e96900;
        background-color: #f8f8f8;
        border-radius: 2px;
    }

    #vcomments pre code {
        font-family: monospace, monospace;
        padding: 0;
        color: #e8eaf6;
        background-color: #272822;
    }

    #vcomments pre[class*="language-"] {
        padding: 1.2em;
        margin: .5em 0;
    }

    #vcomments code[class*="language-"],
    pre[class*="language-"] {
        color: #e8eaf6;
    }

    #vcomments [type="checkbox"]:not(:checked), [type="checkbox"]:checked {
        position: inherit;
        margin-left: -1.3rem;
        margin-right: 0.4rem;
        margin-top: -1px;
        vertical-align: middle;
        left: unset;
        visibility: visible;
    }

    #vcomments b,
    strong {
        font-weight: bold;
    }

    #vcomments dfn {
        font-style: italic;
    }

    #vcomments small {
        font-size: 85%;
    }

    #vcomments cite {
        font-style: normal;
    }

    #vcomments mark {
        background-color: #fcf8e3;
        padding: .2em;
    }

    #vcomments table, th, td {
        padding: 12px 13px;
        border: 1px solid #dfe2e5;
    }

    table tr:nth-child(2n), thead {
        background-color: #fafafa;
    }

    #vcomments table th {
        background-color: #f2f2f2;
        min-width: 80px;
    }

    #vcomments table td {
        min-width: 80px;
    }

    #vcomments [type="checkbox"]:not(:checked), [type="checkbox"]:checked {
        position: inherit;
        margin-left: -1.3rem;
        margin-right: 0.4rem;
        margin-top: -1px;
        vertical-align: middle;
        left: unset;
        visibility: visible;
    }
</style>

<div class="card valine-card" data-aos="fade-up">
    <div class="comment_headling" style="font-size: 20px; font-weight: 700; position: relative; padding-left: 20px; top: 15px; padding-bottom: 5px;">
        <i class="fas fa-comments fa-fw" aria-hidden="true"></i>
        <span>评论</span>
    </div>
    <div id="vcomments" class="card-content" style="display: grid">
    </div>
</div>

<script src="/wangbowen-hexo-blog/libs/valine/av-min.js"></script>
<script src="/wangbowen-hexo-blog/libs/valine/Valine.min.js"></script>
<script>
    new Valine({
        el: '#vcomments',
        appId: 'EDT5zRbrzUXInYp7SCupHY7m-gzGzoHsz',
        appKey: 'u9CyC9PTy66xmdnLhq7Hu8PX',
        notify: 'true' === 'true',
        verify: 'true' === 'true',
        visitor: 'true' === 'true',
        avatar: 'mm',
        pageSize: '10',
        lang: 'zh-cn',
        placeholder: '有好的建议请留言八！'
    });
</script>

<!--酷Q推送-->


    

    

    

    

    

<article id="prenext-posts" class="prev-next articles">
    <div class="row article-row">
        
        <div class="article col s12 m6" data-aos="fade-up">
            <div class="article-badge left-badge text-color">
                <i class="fas fa-chevron-left"></i>&nbsp;上一篇</div>
            <div class="card">
                <a href="/wangbowen-hexo-blog/2023/03/20/typescript11-ts-nei-zhi-gong-ju-lei-xing-ti-cao/">
                    <div class="card-image">
                        
                        
                        <img src="/wangbowen-hexo-blog/medias/featureimages/9.jpg" class="responsive-img" alt="typescript11（TS内置工具-类型体操）">
                        
                        <span class="card-title">typescript11（TS内置工具-类型体操）</span>
                    </div>
                </a>
                <div class="card-content article-content">
                    <div class="summary block-with-text">
                        
                            
                        
                    </div>
                    <div class="publish-info">
                        <span class="publish-date">
                            <i class="far fa-clock fa-fw icon-date"></i>2023-03-20
                        </span>
                        <span class="publish-author">
                            
                            <i class="fas fa-user fa-fw"></i>
                            W.BOWEN
                            
                        </span>
                    </div>
                </div>
                
                <div class="card-action article-tags">
                    
                    <a href="/wangbowen-hexo-blog/tags/typescript/">
                        <span class="chip bg-color">typescript</span>
                    </a>
                    
                </div>
                
            </div>
        </div>
        
        
        <div class="article col s12 m6" data-aos="fade-up">
            <div class="article-badge right-badge text-color">
                下一篇&nbsp;<i class="fas fa-chevron-right"></i>
            </div>
            <div class="card">
                <a href="/wangbowen-hexo-blog/2023/03/11/typescript9-fan-xing/">
                    <div class="card-image">
                        
                        
                        <img src="/wangbowen-hexo-blog/medias/featureimages/21.jpg" class="responsive-img" alt="typescript9（泛型）">
                        
                        <span class="card-title">typescript9（泛型）</span>
                    </div>
                </a>
                <div class="card-content article-content">
                    <div class="summary block-with-text">
                        
                            
                        
                    </div>
                    <div class="publish-info">
                            <span class="publish-date">
                                <i class="far fa-clock fa-fw icon-date"></i>2023-03-11
                            </span>
                        <span class="publish-author">
                            
                            <i class="fas fa-user fa-fw"></i>
                            W.BOWEN
                            
                        </span>
                    </div>
                </div>
                
                <div class="card-action article-tags">
                    
                    <a href="/wangbowen-hexo-blog/tags/typescript/">
                        <span class="chip bg-color">typescript</span>
                    </a>
                    
                </div>
                
            </div>
        </div>
        
    </div>
</article>

</div>



<!-- 代码块功能依赖 -->
<script type="text/javascript" src="/wangbowen-hexo-blog/libs/codeBlock/codeBlockFuction.js"></script>

<!-- 代码语言 -->

<script type="text/javascript" src="/wangbowen-hexo-blog/libs/codeBlock/codeLang.js"></script>


<!-- 代码块复制 -->

<script type="text/javascript" src="/wangbowen-hexo-blog/libs/codeBlock/codeCopy.js"></script>


<!-- 代码块收缩 -->

<script type="text/javascript" src="/wangbowen-hexo-blog/libs/codeBlock/codeShrink.js"></script>


    </div>
    <div id="toc-aside" class="expanded col l3 hide-on-med-and-down">
        <div class="toc-widget card" style="background-color: white;">
            <div class="toc-title"><i class="far fa-list-alt"></i>&nbsp;&nbsp;目录</div>
            <div id="toc-content"></div>
        </div>
    </div>
</div>

<!-- TOC 悬浮按钮. -->

<div id="floating-toc-btn" class="hide-on-med-and-down">
    <a class="btn-floating btn-large bg-color">
        <i class="fas fa-list-ul"></i>
    </a>
</div>


<script src="/wangbowen-hexo-blog/libs/tocbot/tocbot.min.js"></script>
<script>
    $(function () {
        tocbot.init({
            tocSelector: '#toc-content',
            contentSelector: '#articleContent',
            headingsOffset: -($(window).height() * 0.4 - 45),
            collapseDepth: Number('0'),
            headingSelector: 'h2, h3, h4'
        });

        // modify the toc link href to support Chinese.
        let i = 0;
        let tocHeading = 'toc-heading-';
        $('#toc-content a').each(function () {
            $(this).attr('href', '#' + tocHeading + (++i));
        });

        // modify the heading title id to support Chinese.
        i = 0;
        $('#articleContent').children('h2, h3, h4').each(function () {
            $(this).attr('id', tocHeading + (++i));
        });

        // Set scroll toc fixed.
        let tocHeight = parseInt($(window).height() * 0.4 - 64);
        let $tocWidget = $('.toc-widget');
        $(window).scroll(function () {
            let scroll = $(window).scrollTop();
            /* add post toc fixed. */
            if (scroll > tocHeight) {
                $tocWidget.addClass('toc-fixed');
            } else {
                $tocWidget.removeClass('toc-fixed');
            }
        });

        
        /* 修复文章卡片 div 的宽度. */
        let fixPostCardWidth = function (srcId, targetId) {
            let srcDiv = $('#' + srcId);
            if (srcDiv.length === 0) {
                return;
            }

            let w = srcDiv.width();
            if (w >= 450) {
                w = w + 21;
            } else if (w >= 350 && w < 450) {
                w = w + 18;
            } else if (w >= 300 && w < 350) {
                w = w + 16;
            } else {
                w = w + 14;
            }
            $('#' + targetId).width(w);
        };

        // 切换TOC目录展开收缩的相关操作.
        const expandedClass = 'expanded';
        let $tocAside = $('#toc-aside');
        let $mainContent = $('#main-content');
        $('#floating-toc-btn .btn-floating').click(function () {
            if ($tocAside.hasClass(expandedClass)) {
                $tocAside.removeClass(expandedClass).hide();
                $mainContent.removeClass('l9');
            } else {
                $tocAside.addClass(expandedClass).show();
                $mainContent.addClass('l9');
            }
            fixPostCardWidth('artDetail', 'prenext-posts');
        });
        
    });
</script>

    

</main>




    <footer class="page-footer bg-color">
    
        <link rel="stylesheet" href="/wangbowen-hexo-blog/libs/aplayer/APlayer.min.css">
<style>
    .aplayer .aplayer-lrc p {
        
        display: none;
        
        font-size: 12px;
        font-weight: 700;
        line-height: 16px !important;
    }

    .aplayer .aplayer-lrc p.aplayer-lrc-current {
        
        display: none;
        
        font-size: 15px;
        color: #42b983;
    }

    
    .aplayer.aplayer-fixed.aplayer-narrow .aplayer-body {
        left: -66px !important;
    }

    .aplayer.aplayer-fixed.aplayer-narrow .aplayer-body:hover {
        left: 0px !important;
    }

    
</style>
<div class="">
    
    <div class="row">
        <meting-js class="col l8 offset-l2 m10 offset-m1 s12"
                   server="netease"
                   type="playlist"
                   id="503838841"
                   fixed='true'
                   autoplay='true'
                   theme='#42b983'
                   loop='all'
                   order='random'
                   preload='auto'
                   volume='0.7'
                   list-folded='true'
        >
        </meting-js>
    </div>
</div>

<script src="/wangbowen-hexo-blog/libs/aplayer/APlayer.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/meting@2/dist/Meting.min.js"></script>

    
    <div class="container row center-align" style="margin-bottom: 0px !important;">
        <div class="col s12 m8 l8 copy-right">
            Copyright&nbsp;&copy;
            
                <span id="year">2019-2024</span>
            
            <span id="year">2019</span>
            <a href="/wangbowen-hexo-blog/about" target="_blank">W.BOWEN</a>
            |&nbsp;Powered by&nbsp;<a href="https://hexo.io/" target="_blank">Hexo</a>
            |&nbsp;Theme&nbsp;<a href="https://github.com/blinkfox/hexo-theme-matery" target="_blank">Matery</a>
            <br>
            
            
            
            
            
            
            <span id="busuanzi_container_site_pv">
                |&nbsp;<i class="far fa-eye"></i>&nbsp;总访问量:&nbsp;<span id="busuanzi_value_site_pv"
                    class="white-color"></span>&nbsp;次
            </span>
            
            
            <span id="busuanzi_container_site_uv">
                |&nbsp;<i class="fas fa-users"></i>&nbsp;总访问人数:&nbsp;<span id="busuanzi_value_site_uv"
                    class="white-color"></span>&nbsp;人
            </span>
            
            <br>
            
            <br>
            
        </div>
        <div class="col s12 m4 l4 social-link social-statis">
    <a href="https://gitee.com/wang-bowen" class="tooltipped" target="_blank" data-tooltip="访问我的GitHub" data-position="top" data-delay="50">
        <i class="fab fa-github"></i>
    </a>



    <a href="mailto:784801819@qq.com" class="tooltipped" target="_blank" data-tooltip="邮件联系我" data-position="top" data-delay="50">
        <i class="fas fa-envelope-open"></i>
    </a>







    <a href="tencent://AddContact/?fromId=50&fromSubId=1&subcmd=all&uin=784801819" class="tooltipped" target="_blank" data-tooltip="QQ联系我: 784801819" data-position="top" data-delay="50">
        <i class="fab fa-qq"></i>
    </a>







    <a href="/wangbowen-hexo-blog/atom.xml" class="tooltipped" target="_blank" data-tooltip="RSS 订阅" data-position="top" data-delay="50">
        <i class="fas fa-rss"></i>
    </a>

</div>
    </div>
</footer>

<div class="progress-bar"></div>


    <!-- 搜索遮罩框 -->
<div id="searchModal" class="modal">
    <div class="modal-content">
        <div class="search-header">
            <span class="title"><i class="fas fa-search"></i>&nbsp;&nbsp;搜索</span>
            <input type="search" id="searchInput" name="s" placeholder="请输入搜索的关键字"
                   class="search-input">
        </div>
        <div id="searchResult"></div>
    </div>
</div>

<script type="text/javascript">
$(function () {
    var searchFunc = function (path, search_id, content_id) {
        'use strict';
        $.ajax({
            url: path,
            dataType: "xml",
            success: function (xmlResponse) {
                // get the contents from search data
                var datas = $("entry", xmlResponse).map(function () {
                    return {
                        title: $("title", this).text(),
                        content: $("content", this).text(),
                        url: $("url", this).text()
                    };
                }).get();
                var $input = document.getElementById(search_id);
                var $resultContent = document.getElementById(content_id);
                $input.addEventListener('input', function () {
                    var str = '<ul class=\"search-result-list\">';
                    var keywords = this.value.trim().toLowerCase().split(/[\s\-]+/);
                    $resultContent.innerHTML = "";
                    if (this.value.trim().length <= 0) {
                        return;
                    }
                    // perform local searching
                    datas.forEach(function (data) {
                        var isMatch = true;
                        var data_title = data.title.trim().toLowerCase();
                        var data_content = data.content.trim().replace(/<[^>]+>/g, "").toLowerCase();
                        var data_url = data.url;
                        data_url = data_url.indexOf('/') === 0 ? data.url : '/' + data_url;
                        var index_title = -1;
                        var index_content = -1;
                        var first_occur = -1;
                        // only match artiles with not empty titles and contents
                        if (data_title !== '' && data_content !== '') {
                            keywords.forEach(function (keyword, i) {
                                index_title = data_title.indexOf(keyword);
                                index_content = data_content.indexOf(keyword);
                                if (index_title < 0 && index_content < 0) {
                                    isMatch = false;
                                } else {
                                    if (index_content < 0) {
                                        index_content = 0;
                                    }
                                    if (i === 0) {
                                        first_occur = index_content;
                                    }
                                }
                            });
                        }
                        // show search results
                        if (isMatch) {
                            str += "<li><a href='" + data_url + "' class='search-result-title'>" + data_title + "</a>";
                            var content = data.content.trim().replace(/<[^>]+>/g, "");
                            if (first_occur >= 0) {
                                // cut out 100 characters
                                var start = first_occur - 20;
                                var end = first_occur + 80;
                                if (start < 0) {
                                    start = 0;
                                }
                                if (start === 0) {
                                    end = 100;
                                }
                                if (end > content.length) {
                                    end = content.length;
                                }
                                var match_content = content.substr(start, end);
                                // highlight all keywords
                                keywords.forEach(function (keyword) {
                                    var regS = new RegExp(keyword, "gi");
                                    match_content = match_content.replace(regS, "<em class=\"search-keyword\">" + keyword + "</em>");
                                });

                                str += "<p class=\"search-result\">" + match_content + "...</p>"
                            }
                            str += "</li>";
                        }
                    });
                    str += "</ul>";
                    $resultContent.innerHTML = str;
                });
            }
        });
    };

    searchFunc('/wangbowen-hexo-blog/search.xml', 'searchInput', 'searchResult');
});
</script>

    <!-- 回到顶部按钮 -->
<div id="backTop" class="top-scroll">
    <a class="btn-floating btn-large waves-effect waves-light" href="#!">
        <i class="fas fa-arrow-up"></i>
    </a>
</div>


    <script src="/wangbowen-hexo-blog/libs/materialize/materialize.min.js"></script>
    <script src="/wangbowen-hexo-blog/libs/masonry/masonry.pkgd.min.js"></script>
    <script src="/wangbowen-hexo-blog/libs/aos/aos.js"></script>
    <script src="/wangbowen-hexo-blog/libs/scrollprogress/scrollProgress.min.js"></script>
    <script src="/wangbowen-hexo-blog/libs/lightGallery/js/lightgallery-all.min.js"></script>
    <script src="/wangbowen-hexo-blog/js/matery.js"></script>

    <!-- Baidu Analytics -->

    <!-- Baidu Push -->

<script>
    (function () {
        var bp = document.createElement('script');
        var curProtocol = window.location.protocol.split(':')[0];
        if (curProtocol === 'https') {
            bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
        } else {
            bp.src = 'http://push.zhanzhang.baidu.com/push.js';
        }
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(bp, s);
    })();
</script>

    
    <script src="/wangbowen-hexo-blog/libs/others/clicklove.js" async="async"></script>
    
    
    <script async src="/wangbowen-hexo-blog/libs/others/busuanzi.pure.mini.js"></script>
    

    

    

    <!--腾讯兔小巢-->
    
    

    

    

    
    <script src="/wangbowen-hexo-blog/libs/instantpage/instantpage.js" type="module"></script>
    

<script src="/wangbowen-hexo-blog/live2dw/lib/L2Dwidget.min.js?094cbace49a39548bed64abff5988b05"></script><script>L2Dwidget.init({"pluginRootPath":"live2dw/","pluginJsPath":"lib/","pluginModelPath":"assets/","tagMode":false,"debug":false,"model":{"jsonPath":"live2d-widget-model-z16"},"display":{"position":"right","width":200,"height":400},"mobile":{"show":false},"log":false});</script></body>

</html>
